import java.awt.event.KeyEvent;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

public class XTestShow {

	TwinkleApp tm = new TwinkleApp();

	public void showAll() {
		ArrayList<String> names = new ArrayList<String>();
		names.add("cat");
		names.add("dog");
		names.add("cow");
		names.add("duck");
		ArrayList<String> images = new ArrayList<String>();
		images.add("cat.jpg");
		images.add("dog.jpg");
		images.add("cow.jpg");
		images.add("duck.jpg");

		ArrayList<String> sounds = new ArrayList<String>();
		sounds.add("cat.wav");
		sounds.add("dog.wav");
		sounds.add("cow.wav");
		sounds.add("duck.wav");

		ArrayList<String> colors = new ArrayList<String>();
		colors.add("red");
		colors.add("blue");
		colors.add("orange");
		colors.add("green");
		tm.showAll(names, images, sounds, colors, 1);
	}

	public void showIfPressed() {
		String imageFile = "world.jpg";
		String soundFile = "helloWorld";
		tm.showIfPressed("hello world", imageFile, soundFile, "orange", "h", 10);
		// tm.reset();
	}

	public void showIfPressed2() {
		String[] words = { "one", "two", "three", "four" };
		String[] image = { "1.jpg", "2.jpg", "3.jpg", "4.jpg" };
		String[] sound = { "one.wav", "two.wav", "three.wav", "four.wav" };
		String[] key = { "1", "2", "3", "4" };

		ArrayList<String> wordL = new ArrayList(Arrays.asList(words));
		ArrayList<String> imageL = new ArrayList(Arrays.asList(image));
		ArrayList<String> soundL = new ArrayList(Arrays.asList(sound));
		ArrayList<String> keyL = new ArrayList(Arrays.asList(key));

		tm.showIfPressed(wordL, imageL, soundL, null, keyL, 5);
	}

	public void showElementString() {
		String imageFile = "world.jpg";
		String soundFile = "helloWorld.wav";
		tm.show("hello world", imageFile, soundFile, "black");
	}

	public void showMessage() {
		String message = "Emma Woodhouse, handsome, clever, and rich,";
		tm.showMessage(message, "red");
	}

	public void say() {
		String soundFile = "helloWorld.wav";
		tm.say(soundFile);
		tm.display();
		
	}
;
	public void showAndWait() {
		showElementString();
		tm.waitFor(5);
	}

	public void waitFor(long time)
	{
		tm.waitFor(time);
	}
	public void isPressed() {
		tm.display();

		TKeyListener keyListen = tm.getKeyListener();
		Integer keyTyped = keyListen.getKeyTyped();
		while (keyTyped != KeyEvent.VK_ESCAPE) {
			if (keyTyped == KeyEvent.VK_1) {
				System.out.println("has key event 1");
				showElementString();
			} else if (keyTyped == KeyEvent.VK_2) {
				System.out.println("has key event 2");
				showAll();
			}
			keyTyped = keyListen.getKeyTyped();
			System.out.println(" received " + keyTyped);
		}
		System.out.println("exited out of the loop as pressed escape");
		// tm.reset();
	}

	public void showAndTest() {
		String[] names = { "one", "two", "three", "four" };
		String[] keys = { "1", "2", "3", "4" };
		String[] sounds = { "press_key.wav", "press_key.wav", "press_key.wav",
				"press_key.wav" };
		String[] images = { "1.jpg", "2.jpg", "3.jpg", "4.jpg" };
		String[] sucessSounds = { "success_1.wav", "success_2.wav",
				"success_3.wav", "success_4.wav" };

		ArrayList<String> nlist = new ArrayList(Arrays.asList(names));
		ArrayList<String> klist = new ArrayList(Arrays.asList(keys));
		ArrayList<String> ilist = new ArrayList(Arrays.asList(images));
		ArrayList<String> slist = new ArrayList(Arrays.asList(sounds));
		ArrayList<String> sslist = new ArrayList(Arrays.asList(sucessSounds));
		tm.showAndTest(nlist, ilist, null, "press_key.wav", sslist, klist);
		
	}
	
	public void showElementTimeInSec(){
		String imageFile = "world.jpg";
		String soundFile = "helloWorld.wav";
		
		tm.show(new Element("hello world", imageFile, soundFile, "black"), 5);
	}

	public static void main(String[] args) {
		XTestShow test = new XTestShow();
		// System.out.println("" + KeyEvent.VK_1);
		// System.out.println("" + KeyEvent.VK_ESCAPE);
		// System.out.println("" + KeyEvent.VK_2);
		 test.showIfPressed();
		// test.showIfPressed2();
	//	test.isPressed();
// 	 test.say();
 	//test.showMessage();
//	test.waitFor(5);
	 
	// test.showAll();
//		 test.showAndWait();
//		
//		test.showElementString();
//		test.showElementTimeInSec();
//		test.showAndTest();
//		test.showIfPressed2();
		//test.showAndTest();

		// readText.consume("Choose an activity.");

	}
}
